package cn.com.darly.videoandroidpm.ui.presenter;

import com.darly.common.ToastApp;
import com.darly.common.retrofit.FrameListener;

import java.util.Map;

import cn.com.darly.videoandroidpm.bean.BaseBean;
import cn.com.darly.videoandroidpm.ui.biz.VideoAcceptListener;


/**
 * @author zhangyh2 s 上午10:57:39 TODO 控制器 页面动作操作
 */
public class VideoAcceptPresenter {

    private VideoAcceptListener userBiz;
    private VideoAcceptListener.VideoAcceptInterface main;


    public VideoAcceptPresenter(VideoAcceptListener.VideoAcceptInterface main) {
        this.main = main;
        this.userBiz = new VideoAcceptListener();
    }

    public void onAccept(Map<String, String> params) {
        userBiz.accept(params, new FrameListener<BaseBean<String>>() {
            @Override
            public void onSucces(BaseBean<String> info) {
                main.setEnableClick();
                main.onVideoAcceptSuccess(info.getData());
            }

            @Override
            public void onFaild(int code, String info) {
                main.setEnableClick();
                if (code == 0){
                    ToastApp.showToast("服务端更新，请更新应用版本！");
                }else {
                    main.onVideoAcceptFailed(info);
                }
            }
        });
    }

    public void onRefuse(Map<String, String> params) {
        userBiz.refuse(params, new FrameListener<BaseBean<Object>>() {
            @Override
            public void onSucces(BaseBean<Object> info) {
                main.setEnableClick();
            }

            @Override
            public void onFaild(int code, String info) {
                main.setEnableClick();
                ToastApp.showToast("服务端更新，请更新应用版本！");
            }
        });
    }
}